Convert GailProgressBar to GtkProgressBarAccessible
authorMatthias Clasen <mclasen@redhat.com>
Mon, 27 Jun 2011 03:00:20 +0000 (23:00 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 5 Jul 2011 20:08:53 +0000 (16:08 -0400)
gtk/a11y/Makefile.am
gtk/a11y/gail.c
gtk/a11y/gailprogressbar.c [deleted file]
gtk/a11y/gailprogressbar.h [deleted file]
gtk/a11y/gtkprogressbaraccessible.c [new file with mode: 0644]
gtk/a11y/gtkprogressbaraccessible.h [new file with mode: 0644]
gtk/gtkprogressbar.c

index 630b18c8b807cd0fff4049725b37ba1f1c60640e..9f70e2b9f3c0e7e35ef353604d31e692eabfddcf 100644 (file)
@@ -30,7 +30,7 @@ gail_c_sources =                      \
        gailnotebook.c                  \
        gailnotebookpage.c              \
        gailpaned.c                     \
-       gailprogressbar.c               \
+       gtkprogressbaraccessible.c      \
        gailradiobutton.c               \
        gailradiomenuitem.c             \
        gailradiosubmenuitem.c          \
@@ -82,7 +82,7 @@ gail_private_h_sources =              \
        gailnotebook.h                  \
        gailnotebookpage.h              \
        gailpaned.h                     \
-       gailprogressbar.h               \
+       gtkprogressbaraccessible.h      \
        gailradiobutton.h               \
        gailradiomenuitem.h             \
        gailradiosubmenuitem.h          \
index dec6ccd381a3355173a7df53df3020cf34779849..46b7c4516414b492136ceffe00a6178226231447 100644 (file)
@@ -40,7 +40,6 @@
 #include "gailmenuitem.h"
 #include "gailnotebook.h"
 #include "gailpaned.h"
-#include "gailprogressbar.h"
 #include "gailradiobutton.h"
 #include "gailradiomenuitem.h"
 #include "gailrenderercell.h"
@@ -117,7 +116,6 @@ GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_RANGE, GailRange, gail_range, GTK_TYPE_RANGE)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_SCALE_BUTTON, GailScaleButton, gail_scale_button, GTK_TYPE_SCALE_BUTTON)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_STATUSBAR, GailStatusbar, gail_statusbar, GTK_TYPE_STATUSBAR)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_NOTEBOOK, GailNotebook, gail_notebook, GTK_TYPE_NOTEBOOK)
-GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_PROGRESS_BAR, GailProgressBar, gail_progress_bar, GTK_TYPE_PROGRESS_BAR)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_TREE_VIEW, GailTreeView, gail_tree_view, GTK_TYPE_TREE_VIEW)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_RADIO_BUTTON, GailRadioButton, gail_radio_button, GTK_TYPE_RADIO_BUTTON)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_SCROLLED_WINDOW, GailScrolledWindow, gail_scrolled_window, GTK_TYPE_SCROLLED_WINDOW)
@@ -884,7 +882,6 @@ gail_accessibility_module_init (void)
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_SCALE_BUTTON, gail_scale_button);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_STATUSBAR, gail_statusbar);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_NOTEBOOK, gail_notebook);
-  GAIL_WIDGET_SET_FACTORY (GTK_TYPE_PROGRESS_BAR, gail_progress_bar);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_TREE_VIEW, gail_tree_view);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_TEXT, gail_text_cell);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CELL_RENDERER_TOGGLE, gail_boolean_cell);
diff --git a/gtk/a11y/gailprogressbar.c b/gtk/a11y/gailprogressbar.c
deleted file mode 100644 (file)
index cfa6315..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/* GAIL - The GNOME Accessibility Implementation Library
- * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#include <string.h>
-
-#include <gtk/gtk.h>
-
-#include "gailprogressbar.h"
-#include "gailadjustment.h"
-
-static void     gail_progress_bar_class_init        (GailProgressBarClass *klass);
-static void     gail_progress_bar_init              (GailProgressBar *bar);
-static void      gail_progress_bar_real_initialize   (AtkObject      *obj,
-                                                      gpointer       data);
-
-static void     atk_value_interface_init            (AtkValueIface  *iface);
-
-
-static void      gail_progress_bar_real_notify_gtk   (GObject        *obj,
-                                                      GParamSpec     *pspec);
-
-static void     gail_progress_bar_get_current_value (AtkValue       *obj,
-                                                     GValue         *value);
-static void     gail_progress_bar_get_maximum_value (AtkValue       *obj,
-                                                     GValue         *value);
-static void     gail_progress_bar_get_minimum_value (AtkValue       *obj,
-                                                     GValue         *value);
-
-G_DEFINE_TYPE_WITH_CODE (GailProgressBar, gail_progress_bar, GAIL_TYPE_WIDGET,
-                         G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
-
-static void
-gail_progress_bar_class_init           (GailProgressBarClass *klass)
-{
-  AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
-  GailWidgetClass *widget_class;
-
-  widget_class = (GailWidgetClass*)klass;
-
-  widget_class->notify_gtk = gail_progress_bar_real_notify_gtk;
-
-  class->initialize = gail_progress_bar_real_initialize;
-}
-
-static void
-gail_progress_bar_init (GailProgressBar *bar)
-{
-}
-
-static void
-gail_progress_bar_real_initialize (AtkObject *obj,
-                                   gpointer  data)
-{
-  ATK_OBJECT_CLASS (gail_progress_bar_parent_class)->initialize (obj, data);
-
-  obj->role = ATK_ROLE_PROGRESS_BAR;
-}
-
-static void
-atk_value_interface_init (AtkValueIface *iface)
-{
-  iface->get_current_value = gail_progress_bar_get_current_value;
-  iface->get_maximum_value = gail_progress_bar_get_maximum_value;
-  iface->get_minimum_value = gail_progress_bar_get_minimum_value;
-}
-
-static void
-gail_progress_bar_get_current_value (AtkValue   *obj,
-                                     GValue     *value)
-{
-  GtkWidget *widget;
-
-  g_return_if_fail (GAIL_IS_PROGRESS_BAR (obj));
-
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
-
-  memset (value, 0, sizeof (GValue));
-  g_value_init (value, G_TYPE_DOUBLE);
-  g_value_set_double (value, gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget)));
-}
-
-static void
-gail_progress_bar_get_maximum_value (AtkValue   *obj,
-                                     GValue     *value)
-{
-  g_return_if_fail (GAIL_IS_PROGRESS_BAR (obj));
-
-  memset (value, 0, sizeof (GValue));
-  g_value_init (value, G_TYPE_DOUBLE);
-  g_value_set_double (value, 1.0);
-}
-
-static void     
-gail_progress_bar_get_minimum_value (AtkValue    *obj,
-                                    GValue      *value)
-{
-  g_return_if_fail (GAIL_IS_PROGRESS_BAR (obj));
-
-  memset (value, 0, sizeof (GValue));
-  g_value_init (value, G_TYPE_DOUBLE);
-  g_value_set_double (value, 0.0);
-}
-
-static void
-gail_progress_bar_real_notify_gtk (GObject           *obj,
-                                   GParamSpec        *pspec)
-{
-  GtkWidget *widget = GTK_WIDGET (obj);
-  GailProgressBar *progress_bar = GAIL_PROGRESS_BAR (gtk_widget_get_accessible (widget));
-
-  if (strcmp (pspec->name, "fraction") == 0)
-    g_object_notify (G_OBJECT (progress_bar), "accessible-value");
-  else
-    GAIL_WIDGET_CLASS (gail_progress_bar_parent_class)->notify_gtk (obj, pspec);
-}
diff --git a/gtk/a11y/gailprogressbar.h b/gtk/a11y/gailprogressbar.h
deleted file mode 100644 (file)
index 8ca5a7f..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* GAIL - The GNOME Accessibility Implementation Library
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GAIL_PROGRESS_BAR_H__
-#define __GAIL_PROGRESS_BAR_H__
-
-#include "gailwidget.h"
-
-G_BEGIN_DECLS
-
-#define GAIL_TYPE_PROGRESS_BAR                      (gail_progress_bar_get_type ())
-#define GAIL_PROGRESS_BAR(obj)                      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_PROGRESS_BAR, GailProgressBar))
-#define GAIL_PROGRESS_BAR_CLASS(klass)                 (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_PROGRESS_BAR, GailProgressBarClass))
-#define GAIL_IS_PROGRESS_BAR(obj)                      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_PROGRESS_BAR))
-#define GAIL_IS_PROGRESS_BAR_CLASS(klass)              (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_PROGRESS_BAR))
-#define GAIL_PROGRESS_BAR_GET_CLASS(obj)               (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_PROGRESS_BAR, GailProgressBarClass))
-
-typedef struct _GailProgressBar         GailProgressBar;
-typedef struct _GailProgressBarClass   GailProgressBarClass;
-
-struct _GailProgressBar
-{
-  GailWidget parent;
-};
-
-GType gail_progress_bar_get_type (void);
-
-struct _GailProgressBarClass
-{
-  GailWidgetClass parent_class;
-};
-
-G_END_DECLS
-
-#endif /* __GAIL_PROGRESS_BAR_H__ */
diff --git a/gtk/a11y/gtkprogressbaraccessible.c b/gtk/a11y/gtkprogressbaraccessible.c
new file mode 100644 (file)
index 0000000..a75526a
--- /dev/null
@@ -0,0 +1,113 @@
+/* GAIL - The GNOME Accessibility Implementation Library
+ * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#include <gtk/gtk.h>
+
+#include "gtkprogressbaraccessible.h"
+#include "gailadjustment.h"
+
+
+static void atk_value_interface_init (AtkValueIface  *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkProgressBarAccessible, gtk_progress_bar_accessible, GAIL_TYPE_WIDGET,
+                         G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
+
+static void
+gtk_progress_bar_accessible_initialize (AtkObject *obj,
+                                        gpointer   data)
+{
+  ATK_OBJECT_CLASS (gtk_progress_bar_accessible_parent_class)->initialize (obj, data);
+
+  obj->role = ATK_ROLE_PROGRESS_BAR;
+}
+
+static void
+gtk_progress_bar_accessible_notify_gtk (GObject    *obj,
+                                        GParamSpec *pspec)
+{
+  GtkWidget *widget = GTK_WIDGET (obj);
+  AtkObject *accessible;
+
+  accessible = gtk_widget_get_accessible (widget);
+
+  if (strcmp (pspec->name, "fraction") == 0)
+    g_object_notify (G_OBJECT (accessible), "accessible-value");
+  else
+    GAIL_WIDGET_CLASS (gtk_progress_bar_accessible_parent_class)->notify_gtk (obj, pspec);
+}
+static void
+gtk_progress_bar_accessible_class_init (GtkProgressBarAccessibleClass *klass)
+{
+  AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+  GailWidgetClass *widget_class;
+
+  widget_class = (GailWidgetClass*)klass;
+
+  widget_class->notify_gtk = gtk_progress_bar_accessible_notify_gtk;
+
+  class->initialize = gtk_progress_bar_accessible_initialize;
+}
+
+static void
+gtk_progress_bar_accessible_init (GtkProgressBarAccessible *bar)
+{
+}
+
+static void
+gtk_progress_bar_accessible_get_current_value (AtkValue *obj,
+                                               GValue   *value)
+{
+  GtkWidget *widget;
+
+  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
+
+  memset (value, 0, sizeof (GValue));
+  g_value_init (value, G_TYPE_DOUBLE);
+  g_value_set_double (value, gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget)));
+}
+
+static void
+gtk_progress_bar_accessible_get_maximum_value (AtkValue *obj,
+                                               GValue   *value)
+{
+  memset (value, 0, sizeof (GValue));
+  g_value_init (value, G_TYPE_DOUBLE);
+  g_value_set_double (value, 1.0);
+}
+
+static void
+gtk_progress_bar_accessible_get_minimum_value (AtkValue *obj,
+                                               GValue   *value)
+{
+  memset (value, 0, sizeof (GValue));
+  g_value_init (value, G_TYPE_DOUBLE);
+  g_value_set_double (value, 0.0);
+}
+
+static void
+atk_value_interface_init (AtkValueIface *iface)
+{
+  iface->get_current_value = gtk_progress_bar_accessible_get_current_value;
+  iface->get_maximum_value = gtk_progress_bar_accessible_get_maximum_value;
+  iface->get_minimum_value = gtk_progress_bar_accessible_get_minimum_value;
+}
diff --git a/gtk/a11y/gtkprogressbaraccessible.h b/gtk/a11y/gtkprogressbaraccessible.h
new file mode 100644 (file)
index 0000000..80241b9
--- /dev/null
@@ -0,0 +1,51 @@
+/* GAIL - The GNOME Accessibility Implementation Library
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GTK_PROGRESS_BAR_ACCESSIBLE_H__
+#define __GTK_PROGRESS_BAR_ACCESSIBLE_H__
+
+#include "gailwidget.h"
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_PROGRESS_BAR_ACCESSIBLE                      (gtk_progress_bar_accessible_get_type ())
+#define GTK_PROGRESS_BAR_ACCESSIBLE(obj)                      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PROGRESS_BAR_ACCESSIBLE, GtkProgressBarAccessible))
+#define GTK_PROGRESS_BAR_ACCESSIBLE_CLASS(klass)                        (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PROGRESS_BAR_ACCESSIBLE, GtkProgressBarAccessibleClass))
+#define GTK_IS_PROGRESS_BAR_ACCESSIBLE(obj)                       (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PROGRESS_BAR_ACCESSIBLE))
+#define GTK_IS_PROGRESS_BAR_ACCESSIBLE_CLASS(klass)               (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PROGRESS_BAR_ACCESSIBLE))
+#define GTK_PROGRESS_BAR_ACCESSIBLE_GET_CLASS(obj)              (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PROGRESS_BAR_ACCESSIBLE, GtkProgressBarAccessibleClass))
+
+typedef struct _GtkProgressBarAccessible         GtkProgressBarAccessible;
+typedef struct _GtkProgressBarAccessibleClass   GtkProgressBarAccessibleClass;
+
+struct _GtkProgressBarAccessible
+{
+  GailWidget parent;
+};
+
+struct _GtkProgressBarAccessibleClass
+{
+  GailWidgetClass parent_class;
+};
+
+GType gtk_progress_bar_accessible_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GTK_PROGRESS_BAR_ACCESSIBLE_H__ */
index aa1f28dd0bd89741faf8428af2ad995c61d544ea..6d6b067e195fd1c189baca3575317cbf4a1ace9d 100644 (file)
@@ -33,6 +33,8 @@
 #include "gtkprivate.h"
 #include "gtkintl.h"
 
+#include "a11y/gtkprogressbaraccessible.h"
+
 /**
  * SECTION:gtkprogressbar
  * @Short_description: A widget which indicates progress visually
@@ -284,6 +286,8 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class)
                                                              G_PARAM_READWRITE));
 
   g_type_class_add_private (class, sizeof (GtkProgressBarPrivate));
+
+  gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_PROGRESS_BAR_ACCESSIBLE);
 }
 
 static void